cgi-bin/0040755000076700007730000000000007230754532011436 5ustar brettbrettcgi-bin/embpcgi.pl0100555000076700007730000000227507222453531013401 0ustar brettbrett#!/usr/bin/perl ################################################################################### # # Embperl - Copyright (c) 1997-1999 Gerald Richter / ECOS # # You may distribute under the terms of either the GNU General Public # License or the Artistic License, as specified in the Perl README file. # For use with Apache httpd and mod_perl, see also Apache copyright. # # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # ################################################################################### use HTML::Embperl; my $rc = HTML::Embperl::runcgi ; if ($rc) { $time = localtime ; print <Embperl Error

embpcgi Server Error: $rc

Please contact the server administrator, $ENV{SERVER_ADMIN} and inform them of the time the error occurred, and anything you might have done that may have caused the error.

$ENV{SERVER_SOFTWARE} HTML::Embperl $HTML::Embperl::VERSION [$time]

EOT } docs/0040755000076700007730000000000007460127446011061 5ustar brettbrettdocs/calendar.epl0100644000076700007730000000434607257322544013340 0ustar brettbrett[- use lib('../lib'); use Ward; $escmode=0; -] [- if (defined $fdat{month}, $fdat{year}) { $month = $fdat{month}; $year = $fdat{year}; } else { ($year, $month, $day) = Date::Calc::Today(); } @events = get_events(Date::Calc::Month_to_Text($month), $year); warn scalar(@events); -] Oak Hills 8th Ward Calendar of Events [- $fontdef = ''; -] [- $bgcolor = 'bgcolor=white'; -]


[+ @months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $months[$month-1] . " " . $year; +]

[- $firstday = Date::Calc::Day_of_Week($year, $month, 1); @days = (2, 3, 4, 5, 6, 7, 1); $firstday = $days[$firstday-1]; $monthdays = Date::Calc::Days_in_Month($year, $month); $daycount = 1; $sevencount = 0; $ended = 0; -] [$ foreach $i (1..43) $] [$ if $ended == 1 $] [$ else $] [$ if (($i < $firstday) || ($daycount > $monthdays)) $] [$ else $] [- $daycount++ -] [$ endif $] [- $sevencount++ -] [$ if ($sevencount == 7) $] [$ if ($daycount > $monthdays) $] [- $ended = 1 -] [$ else $] [- $sevencount = 0 -] [$ endif $] [$ endif $] [$ endif $] [$ endforeach $]
[+ $fontdef +]Sunday [+ $fontdef +]Monday [+ $fontdef +]Tuesday [+ $fontdef +]Wednesday [+ $fontdef +]Thursday [+ $fontdef +]Friday [+ $fontdef +]Saturday
[+ $fontdef +] [+ $fontdef +] [+ $daycount +] [$ foreach $ev (@events) $] [- ($day) = ($ev->{date} =~ /\d{4}-\d{2}-(\d{2})/); -] [$ if $day == $daycount $]

[+ $ev->get_link() +] [$ endif $] [$ endforeach $]
docs/admin/0040755000076700007730000000000007460130032012132 5ustar brettbrettdocs/admin/tmp.epl0100644000076700007730000000024307222737232013443 0ustar brettbrett[- use lib('../../lib'); use WardAdmin; $escmode=0; -] Add a Member [+ get_html; +] docs/admin/mbr_ae1.epl0100644000076700007730000004270207244120745014156 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = (defined $fdat{'mode'}) ? $fdat{'mode'} : 'add'; $retval = ''; if ($mode eq 'edit') { $mbr = get_member($fdat{'mbr_id'}); } else { $mbr = Member->new(); $mbr->set('state' => 'UT'); } @months = ("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); -] [$ if ($mode eq 'edit') $] OH8 Edit Member Form [$ else $] OH8 Add Member Form [$ endif $]
First Name: Middle Name: Last Name:
Address:
City: State: Zip:
Phone: Work Phone: Cell Phone: Pager:
Email Address:
Birthday: [+ if ($mbr->{'birthday'} =~ /(\d{4})-(\d{2})-(\d{2})/) { ($y, $m, $d) = ($mbr->{'birthday'} =~ /(\d{4})-(\d{2})-(\d{2})/); } else { ($y, $m, $d) = ('', '', ''); } $retval = "\n"; $retval .= "\n"; $retval .= qq{\n}; $retval; +]
Where From:
Gender:
Occupation:
Student: School: Major:
Career Objective:
Hobbies:
Instrument Played: How Many Years:
Piano: Chorister: Singing: Computer: Activities:
Teaching: Sports: Photography: Service: Clerical:
Served Mission: Served Where:
Mission Start Date: [+ if ($mbr->{'mission_start'} =~ /(\d{4})-(\d{2})/) { ($y, $m) = ($mbr->{'mission_start'} =~ /(\d{4})-(\d{2})/); } else { ($y, $m) = ('', ''); } $retval = "\n"; $retval .= qq{\n}; $retval; +] Mission End Date: [+ if ($mbr->{'mission_end'} =~ /(\d{4})-(\d{2})/) { ($y, $m) = ($mbr->{'mission_end'} =~ /(\d{4})-(\d{2})/); } else { ($y, $m) = ('', ''); } $retval = "\n"; $retval .= qq{\n}; $retval; +]
Date Joined Ward: [+ if ($mbr->{'joined'} =~ /(\d{4})-(\d{2})-(\d{2})/) { ($y, $m, $d) = ($mbr->{'joined'} =~ /(\d{4})-(\d{2})-(\d{2})/); } else { ($y, $m, $d) = ('', '', ''); } $retval = "\n"; $retval .= "\n"; $retval .= qq{\n}; $retval; +]
Image File Name:
docs/admin/ev_ae.epl0100644000076700007730000002607307257176512013741 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = $fdat{'mode'}; $todo_mode = ''; $msg = ''; if (! defined $mode) { $mode = 'display_add'; } $type = (defined $fdat{'type'}) ? $fdat{'type'} : 'one-time'; if ($mode eq 'do_add') { $ev = Event->new(); foreach $key (keys %$ev) { if (defined $ev->{$key}) { $ev->set($key => $fdat{$key}); } } my $res = add_event($ev); if ($res == 1) { $msg .= "Event successfully added."; $ev = Event->new(); $mode = 'display_add'; } else { $msg .= "Event was not successfully added."; } } elsif ($mode eq 'do_edit') { $ev = Event->new(); foreach $key (keys %$ev) { if (defined $ev->{$key}) { $ev->set($key => $fdat{$key}); } } my $res = edit_event($ev); if ($res == 1) { $msg .= "Event successfully modified."; $mode = 'display_edit'; } else { $msg .= "Event was not successfully modified."; } } if ($mode eq 'display_add') { $ev = Event->new(); $todo_mode = 'do_add'; if ($type eq 'exception') { $ev->{'exception_to'} = $fdat{'exception_to'}; $rec = get_event($ev->{'exception_to'}); $ev->set('contact', $rec->{'contact'}); $ev->set('sdesc', $rec->{'sdesc'}); } } elsif ($mode eq 'display_edit') { $ev = get_event($fdat{'ev_id'}); $todo_mode = 'do_edit'; if (($ev->{'recurring'} eq 'no') && ($ev->{'exception_to'} ne '')) { $type = 'exception'; } elsif ($ev->{'recurring'} eq 'yes') { $type = 'recurring'; } else { $type = 'one-time'; } } if ($mode =~ /edit/) { if ($type eq 'recurring') { $title = "Edit a Recurring Event"; } elsif ($type eq 'exception') { $title = "Provide Details For a Specific date: $ev->{'sdesc'}"; } else { $title = "Edit a One-Time Event"; } } else { if ($type eq 'recurring') { $title = "Add a Recurring Event"; } elsif ($type eq 'exception') { $title = "Provide Details For a Specific date: $ev->{'sdesc'}"; } else { $title = "Add a One-Time Event"; } } @months = ("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); if ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/) { ($y, $m, $d) = ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/); if (length($m) > 1) { ($m) = ($m =~ /\d(\d)/); } $month = $months[$m]; $year = $y; } elsif (defined $fdat{'month'}, $fdat{'year'}) { $month = $fdat{'month'}; $year = $fdat{'year'}; } -] [+ $title +] [- $fontdef = ''; -]
[+ $msg +]
[+ $fontdef +]
[- $ev->set('recurring', ($type eq 'recurring') ? 'yes' : 'no'); -] [$ if ($type eq 'exception') $] [- $exception_to = (defined $fdat{'exception_to'}) ? $fdat{'exception_to'} : $ev->{'exception_to'}; $ev->set('exception_to', $exception_to); -] [$ endif $] [$ if ($ev->{'recurring'} ne 'yes') $] [$ if (defined $month, $year) $] [$ else $] [$ endif $] [$ endif $] [$ if $type eq 'exception' $] [$ else $] [$ endif $] [$ if $type eq 'exception' $] [$ else $] [$ endif $] [$ if (($mode =~ /edit/) || ($type eq 'exception')) $] [$ else $] [$ endif $]
[+ $fontdef +] Weekday [+ $fontdef +]
[+ $fontdef +] Date:[+ $fontdef +] [+ if ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/) { ($y, $m, $d) = ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/); } else { ($y, $m, $d) = ('', '', ''); } $monval = ''; for ($i = 1; $i < scalar(@months); $i++) { if (lc($months[$i]) eq lc($month)) { $monval = $i; } } if (length($monval) < 2) { $monval = '0' . $monval; } $retval = "\n"; $retval .= "$month\n"; $retval .= "\n"; $retval .= "\n"; $retval .= "$year\n"; $retval; +] [+ $fontdef +] [+ if ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/) { ($y, $m, $d) = ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/); } else { ($y, $m, $d) = ('', '', ''); } $retval = "\n"; $retval .= "\n"; $retval .= "\n"; $retval; +]
[+ $fontdef +] Time (HH:MM:SS) [+ $fontdef +]
[+ $fontdef +] Location [+ $fontdef +]
[+ $fontdef +] Short Description [+ $fontdef +]
[+ $fontdef +] Long Description [+ $fontdef +]
[+ $fontdef +] Contact [+ $fontdef +] [$ if $ev->{'contact'} ne '' $] [+ my $mbr = get_member($ev->{'contact'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +]      change: [$ endif $]
[+ $fontdef +] Ward Organization [+ $fontdef +]
[+ $fontdef +] Image 1 [+ $fontdef +]
[+ $fontdef +] Image 2 [+ $fontdef +]
[+ $fontdef +] Link 1 [+ $fontdef +]
[+ $fontdef +] Link 1 [+ $fontdef +]
[+ $fontdef +] Posted By [+ $fontdef +] [$ if $ev->{'posted_by'} ne '' $] [+ my $mbr = get_member($ev->{'posted_by'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +]      change: [$ endif $]
[+ $fontdef +] Cancelled [+ $fontdef +]

[+ $fontdef +]
docs/admin/callings.epl0100644000076700007730000002142407244116172014441 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = $fdat{'mode'}; if (! defined $mode) { $mode = 'display'; } if ($mode eq 'add_calling') { $calling = Calling->new(); $calling->set('call_id' => 0); $calling->set('org_id' => $fdat{'org_id'}); $calling->set('call_title' => $fdat{'call_title'}); $calling->set('call_rank' => $fdat{'call_rank'}); $calling->set('call_multi' => $fdat{'call_multi'}); add_calling($calling); } elsif ($mode eq 'edit_calling') { $calling = Calling->new(); $calling->set('call_id' => $fdat{'call_id'}); $calling->set('org_id' => $fdat{'org_id'}); $calling->set('call_title' => $fdat{'call_title'}); $calling->set('call_rank' => $fdat{'call_rank'}); $calling->set('call_multi' => $fdat{'call_multi'}); edit_calling($calling); } elsif ($mode eq 'do_staff_edit') { alter_mbrcalling($fdat{'call_id'}, $fdat{'old_mbr_id'}, $fdat{'new_mbr_id'}, $fdat{'setapart'}); } -] [- $orgs = get_all_orgs(); @orglist = list_orgs(); -] OH8 Callings
[- $fontdef = qq{}; -]
[$ if $fdat{'org_id'} $] [- $org = get_org($fdat{'org_id'}); $bgcolor = "bgcolor=lightblue"; -] [$ endif $]
[+ $fontdef +]
[+ $fontdef +] Possible Callings

[- $callings = $org->{'callings'}; @callings = @$callings; -] [$ foreach $calling (@callings) $] [$ endforeach $]
[+ $fontdef +]call_id [+ $fontdef +]call_title [+ $fontdef +]call_rank [+ $fontdef +]call_multi
[+ $fontdef +][+ $calling->{'call_id'} +] [+ $fontdef +][+ $calling->{'call_title'} +] [+ $fontdef +][+ $calling->{'call_rank'} +] [+ $fontdef +][+ $calling->{'call_multi'} +]
[+ $fontdef +]add: [+ $fontdef +]Title: [+ $fontdef +]Rank: [+ $fontdef +]Multi:
[+ $fontdef +] [+ $fontdef +] [+ $fontdef +]
[+ $fontdef +]edit: [+ $fontdef +]ID: [+ $fontdef +]Title: [+ $fontdef +]Rank: [+ $fontdef +]Multi:
[+ $fontdef +] [+ $fontdef +] [+ $fontdef +] [+ $fontdef +]
[+ $fontdef +] Callings Personnel

[- $staff = $org->{'staff'}; @staff = @$staff; $callings = $org->{'callings'}; @callings = @$callings; -] [$ foreach $calling (@callings) $] [- $blankmbr = Member->new(); $blankmbr->set('mbrfield' => ' '); @mbrs = ($blankmbr); foreach $mbr (@staff) { $call_id = $calling->{'call_id'}; if ((defined $mbr->{'call_id'}) && ($mbr->{'call_id'} == $call_id)) { $mftmp = $mbr->{'fname'} . ' ' . $mbr->{'lname'}; $mbr->set('mbrfield' => $mftmp); push(@mbrs, $mbr); } } if (($mode eq 'show_staff_edit') && ($fdat{'type'} =~ /add another/) && ($calling->{'call_id'} == $fdat{'call_id'})) { $multimbr = Member->new(); $multimbr->set('mbrfield' => ' '); push(@mbrs, $multimbr); } -] [$ foreach $mbr (@mbrs) $] [$ if (($mbr->{'mbrfield'} eq ' ') && (scalar(@mbrs) > 1)) $] [- # do nothing (for lack of 'next' command in embperl) -] [$ else $] [$ if (($mode eq 'show_staff_edit') && ($mbr->{'mbr_id'} == $fdat{'mbr_id'}) && ($fdat{'type'} eq "edit") && ($calling->{'call_id'} == $fdat{'call_id'})) $] {'call_id'} +]> {'mbr_id'} +]> [$ elsif $mbr->{'mbrfield'} eq ' ' $] {'call_id'} +]> [$ else $] {'call_id'} +]> {'mbr_id'} +]> [$ endif $] [$ endif $] [$ endforeach $] [$ endforeach $]
[+ $fontdef +]Calling [+ $fontdef +]Member [+ $fontdef +]Set Apart [+ $fontdef +]Options
[+ $fontdef +][+ $calling->{'call_title'} +] [+ $fontdef +][+ $mbr->{'mbrfield'} +] [+ $fontdef +] [+ ((defined $mbr->{'setapart'}) && ($mbr->{'setapart'} ne '')) ? $mbr->{'setapart'} : ' ' +]
[+ $fontdef +] set apart:
[+ $fontdef +] set apart:
[+ $fontdef +] [$ if $calling->{'call_multi'} eq 'yes' && $mbr->{'mbr_id'} ne '' $] [$ endif $]
docs/admin/org_ae.epl0100644000076700007730000000701107244115262014074 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = $fdat{'mode'}; if (! defined $mode) { $mode = 'display'; } $retval = ''; if ($mode eq 'add') { $org = Org->new(); $org->set('org_id' => 0); $org->set('org_name' => $fdat{'org_name'}); $org->set('org_nickname' => $fdat{'org_nickname'}); add_org($org); } elsif ($mode eq 'edit') { $org = Org->new(); $org->set('org_id' => $fdat{'org_id'}); $org->set('org_name' => $fdat{'org_name'}); $org->set('org_nickname' => $fdat{'org_nickname'}); edit_org($org); } -] OH8 - Ward Organizations

Ward Organizations

[+ $retval = ''; $orgs = get_all_orgs('no_members'); @orglist = list_orgs(); foreach $org (@orglist) { $org = $orgs->{$org}; $retval .= ""; $retval .= qq{"; $retval .= qq{"; $retval .= qq{"; $retval .= ""; } $retval; +]
org_id org_name org_nickname
}; $retval .= "$org->{'org_id'}}; $retval .= "$org->{'org_name'}}; $retval .= "$org->{'org_nickname'}


Add an Organization
Name:
Nickname:


Edit an Organization
org_id:
Name:
Nickname:
docs/admin/dropdown.epl0100644000076700007730000000231207230157722014475 0ustar brettbrett[- use lib('../../lib'); use WardAdmin; $escmode=0; -] Dropdown Test Page [+ get_mbr_list() +]
first letter of last name:
person: docs/admin/mbr_ae2.epl0100644000076700007730000000070707237453727014171 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = $fdat{'mode'}; -] [+ $mbr = Member->new(); $retval = ''; foreach $key (keys %$mbr) { if (defined $mbr->{$key}) { $mbr->set($key => $fdat{$key}); } } foreach $key (keys %$mbr) { if (defined $mbr->{$key}) { $retval .= "$key: $mbr->{$key}
\n"; } } if ($mode eq 'edit') { edit_member($mbr); } else { add_member($mbr); } $retval; +] docs/admin/mbr_del.epl0100644000076700007730000000134107257214265014253 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = $fdat{'mode'}; if (! defined $mode) { $mode = 'display'; } if ($mode eq 'delete') { $mbr = Member->new(); $mbr->set('mbr_id' => $fdat{'mbr_id'}); delete_member($mbr); } elsif ($mode eq 'undelete') { $mbr = Member->new(); $mbr->set('mbr_id' => $fdat{'mbr_id'}); undelete_member($mbr); } -] OH8 - Delete/Undelete a Member [- $fontdef = '' -]


[+ $fontdef +] Operation Successful

docs/admin/editorg.epl0100644000076700007730000000223207241470574014304 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] OH8 - Ward Organizations
Edit an Organization
org_id:
Name:
Nickname:
docs/admin/index.epl0100644000076700007730000000177407460122140013752 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] OH8 Admin Area
docs/admin/index.html0100644000076700007730000000020307243610453014130 0ustar brettbrett docs/admin/org_email.epl0100644000076700007730000000366707243640537014622 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = $fdat{'mode'}; if (! defined $mode) { $mode = 'display'; } $msg = ''; if ($mode eq 'send') { $ret = send_org_email($fdat{'org_id'}, $fdat{'from'}, $fdat{'subject'}, $fdat{'body'}); if ($ret == 1) { $msg .= "Message successfully sent

"; } } -] OH8 - Send Email to the Members of an Organization [- $fontdef = ''; -]
[+ $fontdef +] [+ $msg +]
[+ $fontdef +] Select An Organization

[+ $fontdef +] Enter a "From" Address (replies will go to this address)

[+ $fontdef +] Enter a Subject Line

[+ $fontdef +] Enter the Body of the Message
docs/admin/ev_list.epl0100644000076700007730000002204407257177300014315 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; use Date::Calc; $escmode=0; -] [- if (defined $fdat{'mode'}) { $mode = $fdat{'mode'}; } else { $mode = 'display'; } $msg = ''; if ($mode eq 'delete') { $success = delete_event($fdat{'ev_id'}); if ($success) { $msg .= "Event successfully deleted
\n"; } else { $msg .= "Event not successfully deleted
\n"; } } elsif ($mode eq 'undelete') { $success = undelete_event($fdat{'ev_id'}); if ($success) { $msg .= "Event successfully undeleted
\n"; } else { $msg .= "Event not successfully undeleted
\n"; } } # If we've deleted or undeleted a one-time event or an exception to a # recurring event, display that event's month after doing so. If we've # deleted or undeleted a recurring event, display the month passed from # the calling page. If none of this has happened, display the month passed. # If no month passed, display the current month. if (($mode eq 'delete') || ($mode eq 'undelete')) { $ev = get_event($fdat{'ev_id'}); if ($ev->{'recurring'} eq 'yes') { if (defined $fdat{'month'}, $fdat{'year'}) { $month = $fdat{'month'}; $year = $fdat{'year'}; } else { ($year, $m, $d) = Date::Calc::Today(); $month = Date::Calc::Month_to_Text($m); } } else { ($year, $m, $d) = ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/); $month = Date::Calc::Month_to_Text($m); } } elsif (defined $fdat{'month'}, $fdat{'year'}) { $month = $fdat{'month'}; $year = $fdat{'year'}; } else { ($year, $month, $d) = Date::Calc::Today(); $month = Date::Calc::Month_to_Text($month); } @events = get_events($month, $year, 'no_setup'); @onetime = (); @recur = (); @exceptions = (); foreach $ev (@events) { if ($ev->{'recurring'} eq 'yes') { push(@recur, $ev); } elsif ($ev->{'exception_to'} ne '') { push(@exceptions, $ev); } else { push(@onetime, $ev); } } # this sets up the @recur array to be an # event followed by its exceptions. foreach $ev (@recur) { push(@tmp, $ev); foreach $exception (@exceptions) { if ($exception->{'exception_to'} eq $ev->{'ev_id'}) { push(@tmp, $exception); } } } @recur = @tmp; %weekdays = ('sun' => 'Sunday', 'mon' => 'Monday', 'tue' => 'Tuesday', 'wed' => 'Wednesday', 'thu' => 'Thursday', 'fri' => 'Friday', 'sat' => 'Saturday'); -] OH8 - Manage Events for [+ $month . ' ' . $year +]

[$ if $msg ne '' $] [+ $msg +]

[$ endif $] [- $fontdef = ''; -] Manage Events for [+ $month . ' ' . $year+]

[+ $fontdef +]
Select a Different Month:


One-Time Events
[- $bgcolor = 'bgcolor=gray'; -] [- $bgcolor = 'bgcolor=white'; -] [$ foreach $ev (@onetime) $] [$ endforeach $]
[+ $fontdef +]   [+ $fontdef +] Event ID [+ $fontdef +] Short Description [+ $fontdef +] When [+ $fontdef +] Where [+ $fontdef +] Contact
[+ $fontdef +] Edit   |   Delete [+ $fontdef +] [+ $ev->{'ev_id'} +] [+ $fontdef +] [+ $ev->{'sdesc'} +] [+ $fontdef +] [+ if ($ev->{'date'} ne '') { $ev->{'date'} . ' ' . $ev->{'time'}; } else { " "; } +] [+ $fontdef +] [+ $ev->{'location'} ne '' ? $ev->{'location'} : ' '; +] [+ $fontdef +] [+ my $mbr = get_member($ev->{'contact'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +]




Recurring Events
[- $bgcolor = 'bgcolor=gray'; -] [- $bgswitch = 1; -] [$ foreach $ev (@recur) $] [- if ($ev->{'recurring'} eq 'yes') { $bgswitch++; if ($bgswitch % 2 == 0) { $bgcolor = 'bgcolor=lightblue'; } else { $bgcolor = 'bgcolor=#D1E4ED'; } } -] [$ if ($ev->{'recurring'} eq 'yes') $] [$ else $] [$ endif $] [$ endforeach $]
[+ $fontdef +]   [+ $fontdef +] Event ID [+ $fontdef +] Short Description [+ $fontdef +] When [+ $fontdef +] Where [+ $fontdef +] Contact [+ $fontdef +]  
[+ $fontdef +] Edit   |   Delete [+ $fontdef +] [+ $ev->{'ev_id'} +] [+ $fontdef +] [+ ($ev->{'exception_to'}) ? ' ' : $ev->{'sdesc'} +] [+ $fontdef +] [+ $ret = ''; if ($ev->{'recurring'} eq 'yes') { $ret = "every $weekdays{$ev->{'weekday'}}"; } else { $ret = $ev->{'date'} . ' ' . $ev->{'time'}; } $ret = ($ret eq '') ? ' ' : $ret; +] [+ $fontdef +] [+ $ev->{'location'} ne '' ? $ev->{'location'} : ' '; +] [+ $fontdef +] [+ my $mbr = get_member($ev->{'contact'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +] [+ $fontdef +] provide details for a specific date [+ $fontdef +]  




Deleted Events
docs/admin/ev_del.epl0100644000076700007730000001237007255007523014104 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- if (defined $fdat{'mode'}) { $mode = $fdat{'mode'}; } else { $mode = 'list_delete'; } if (($mode eq 'display_delete') || ($mode eq 'display_undelete')) { if (! defined $fdat{'ev_id'}) { die "no ev_id specified"; } $ev = get_event($fdat{'ev_id'}); @show_fields = CONST::get_fields('events'); } -] [- if ($mode eq 'display_delete') { $title = "Delete Event: $ev->{'ev_id'}"; } elsif ($mode eq 'display_undelete') { $title = "Undelete Event: $ev->{'ev_id'}"; } elsif ($mode eq 'list_delete') { $title = "Delete Events"; } elsif ($mode eq 'list_undelete') { $title = "Undelete Events"; } -] [+ $title +]
[- $fontdef = ''; -] [$ if (($mode eq 'display_delete') || ($mode eq 'display_undelete')) $] [- if ($mode eq 'display_undelete') { $todo_mode = 'undelete'; $hdr_text = 'Undelete Event'; } else { $todo_mode = 'delete'; $hdr_text = 'Delete Event'; } -] [+ $hdr_text +]

[$ foreach $field (@show_fields) $] [$ endforeach $]
[+ $fontdef +] [+ $field +] [+ $fontdef +] [$ if (($field eq 'contact') || ($field eq 'posted_by')) $] [+ $mbr = get_member($ev->{$field}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +] [$ elsif ($field eq 'org_id') $] [+ $org = get_org($ev->{$field}); "$org->{'org_id'} ($org->{'org_name'})"; +] [$ else $] [+ $ev->{$field} eq '' ? ' ' : $ev->{$field} +] [$ endif $]

[$ if (($mode eq 'display_delete') && ($ev->{'recurring'} eq 'yes')) $]
You are about to delete a recurring event. This means [+ $ev->{'sdesc'} +] will no longer automatically show up on its regularly scheduled day, and any details for specific dates will also be deleted.

[$ elsif (($mode eq 'display_undelete') && ($ev->{'recurring'} eq 'yes')) $]
You are about to undelete a recurring event. Any details for specific dates will not be undeleted with this event. If you proceed, please check the "Undelete Events" list for any specific dates of this event that you would like to undelete as well.

[$ endif $]
[$ if defined $fdat{'month'}, $fdat{'year'} $] [$ endif $] Are you sure you want to [+ $todo_mode +] this event?
[- $noloc = '/cgi-bin/embpcgi.pl/admin/ev_list.epl'; if (defined $fdat{'month'}, $fdat{'year'}) { $noloc .= "?month=" . $fdat{'month'} . "&year=" . $fdat{'year'}; } -]
[$ elsif (($mode eq 'list_undelete') || ($mode eq 'list_delete')) $] [- if ($mode eq 'list_undelete') { @events = get_deleted_events(); $todo_mode = 'display_undelete'; $link_text = 'Undelete'; } else { @events = get_events('all'); $todo_mode = 'display_delete'; $link_text = 'Delete'; } -]
[- $bgcolor = 'bgcolor=gray'; -] [- $bgcolor = 'bgcolor=white'; -] [$ foreach $ev (@events) $] [$ endforeach $]
[+ $fontdef +]   [+ $fontdef +] Event ID [+ $fontdef +] Short Description [+ $fontdef +] When [+ $fontdef +] Where [+ $fontdef +] Contact
[+ $fontdef +] [- $linkhref = "/cgi-bin/embpcgi.pl/admin/ev_del.epl"; $linkhref .= "?mode=$todo_mode&ev_id=$ev->{'ev_id'}"; if (defined $fdat{'month'}, $fdat{'year'}) { $linkhref .= "&month=" . $fdat{'month'} . "&year=" . $fdat{'year'}; } -] [+ $link_text +] [+ $fontdef +] [+ $ev->{'ev_id'} +] [+ $fontdef +] [+ $ev->{'sdesc'} +] [+ $fontdef +] [+ if ($ev->{'date'} ne '') { $ev->{'date'} . ' ' . $ev->{'time'}; } else { " "; } +] [+ $fontdef +] [+ $ev->{'location'} ne '' ? $ev->{'location'} : ' '; +] [+ $fontdef +] [+ my $mbr = get_member($ev->{'contact'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +]
[$ endif $]
docs/admin/ev_ae.epl.bk0100644000076700007730000002265007257156323014327 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- $mode = $fdat{'mode'}; $todo_mode = ''; $msg = ''; if (! defined $mode) { $mode = 'display_add'; } $type = (defined $fdat{'type'}) ? $fdat{'type'} : 'one-time'; if ($mode eq 'do_add') { $ev = Event->new(); foreach $key (keys %$ev) { if (defined $ev->{$key}) { $ev->set($key => $fdat{$key}); } } my $res = add_event($ev); if ($res == 1) { $msg .= "Event successfully added."; $ev = Event->new(); $mode = 'display_add'; } else { $msg .= "Event was not successfully added."; } } elsif ($mode eq 'do_edit') { $ev = Event->new(); foreach $key (keys %$ev) { if (defined $ev->{$key}) { $ev->set($key => $fdat{$key}); } } my $res = edit_event($ev); if ($res == 1) { $msg .= "Event successfully modified."; $mode = 'display_edit'; } else { $msg .= "Event was not successfully modified."; } } if ($mode eq 'display_add') { $ev = Event->new(); $todo_mode = 'do_add'; if ($type eq 'exception') { $ev->{'exception_to'} = $fdat{'exception_to'}; $rec = get_event($ev->{'exception_to'}); $ev->set('contact', $rec->{'contact'}); $ev->set('sdesc', $rec->{'sdesc'}); } } elsif ($mode eq 'display_edit') { $ev = get_event($fdat{'ev_id'}); $todo_mode = 'do_edit'; if (($ev->{'recurring'} eq 'no') && ($ev->{'exception_to'} ne '')) { $type = 'exception'; } elsif ($ev->{'recurring'} eq 'yes') { $type = 'recurring'; } else { $type = 'one-time'; } } if ($mode =~ /edit/) { if ($type eq 'recurring') { $title = "Edit a Recurring Event"; } elsif ($type eq 'exception') { $title = "Provide Details For a Specific date: $ev->{'sdesc'}"; } else { $title = "Edit a One-Time Event"; } } else { if ($type eq 'recurring') { $title = "Add a Recurring Event"; } elsif ($type eq 'exception') { $title = "Provide Details For a Specific date: $ev->{'sdesc'}"; } else { $title = "Add a One-Time Event"; } } @months = ("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); -] [+ $title +] [- $fontdef = ''; -]
[+ $msg +]
[+ $fontdef +]
[- $ev->set('recurring', ($type eq 'recurring') ? 'yes' : 'no'); -] [$ if ($type eq 'exception') $] [- $exception_to = (defined $fdat{'exception_to'}) ? $fdat{'exception_to'} : $ev->{'exception_to'}; $ev->set('exception_to', $exception_to); -] [$ endif $] [$ if ($ev->{'recurring'} ne 'yes') $] [$ endif $] [$ if $type eq 'exception' $] [$ else $] [$ endif $] [$ if $type eq 'exception' $] [$ else $] [$ endif $] [$ if (($mode =~ /edit/) || ($type eq 'exception')) $] [$ else $] [$ endif $]
[+ $fontdef +] Weekday [+ $fontdef +]
[+ $fontdef +] Date: [+ $fontdef +] [+ if ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/) { ($y, $m, $d) = ($ev->{'date'} =~ /(\d{4})-(\d{2})-(\d{2})/); } else { ($y, $m, $d) = ('', '', ''); } $retval = "\n"; $retval .= "\n"; $retval .= qq{\n}; $retval; +]
[+ $fontdef +] Time (HH:MM:SS) [+ $fontdef +]
[+ $fontdef +] Location [+ $fontdef +]
[+ $fontdef +] Short Description [+ $fontdef +]
[+ $fontdef +] Long Description [+ $fontdef +]
[+ $fontdef +] Contact [+ $fontdef +] [$ if $ev->{'contact'} ne '' $] [+ my $mbr = get_member($ev->{'contact'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +]      change: [$ endif $]
[+ $fontdef +] Ward Organization [+ $fontdef +]
[+ $fontdef +] Image 1 [+ $fontdef +]
[+ $fontdef +] Image 2 [+ $fontdef +]
[+ $fontdef +] Link 1 [+ $fontdef +]
[+ $fontdef +] Link 1 [+ $fontdef +]
[+ $fontdef +] Posted By [+ $fontdef +] [$ if $ev->{'posted_by'} ne '' $] [+ my $mbr = get_member($ev->{'posted_by'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +]      change: [$ endif $]
[+ $fontdef +] Cancelled [+ $fontdef +]

[+ $fontdef +]
docs/admin/mbr_list.epl0100644000076700007730000000437607257214532014472 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] OH8: Manage Members [- $fontdef = '' -]

[+ $fontdef +]
[+ $fontdef +]
[+ $fontdef +]
[+ $fontdef +]

[+ $fontdef +]
docs/admin/mbr_restricted.epl0100644000076700007730000000417607257236764015700 0ustar brettbrett[- use lib('../../lib'); use Ward; use WardAdmin; $escmode=0; -] [- if ((defined $fdat{mode}) && ($fdat{mode} eq 'update')) { $to_restrict = []; foreach $key (keys %fdat) { if ($fdat{$key} eq 'on') { push(@$to_restrict, $key); } } $success = set_mbr_restricted($fdat{mbr_id}, $to_restrict); if ($success) { $msg = "Update was successful"; } else { $msg = "Update was not successful"; } } $mbr = get_member($fdat{mbr_id}); @restricted = get_mbr_restricted($fdat{mbr_id}); @mbr_fields = CONST::get_fields('members'); # the following is to override Embperl's special handling of checkboxes so # that the 'checked' attribute will actually show up after a submission. undef %fdat; -] OH8: Restricted Info: [+ $mbr->{fname} +] [+ $mbr->{lname} +] [- $fontdef = '' -] [- $bgcolor = 'bgcolor=white' -]

[$ if defined $msg $] [+ $msg +]

[$ endif $] Manage Restricted Information for [+ $mbr->{fname} +] [+ $mbr->{lname} +]

(Checked fields will be restricted.)

[- $colcount = 0 -] [$ foreach $field (@mbr_fields) $] [- $colcount++ -] [$ if (($colcount % 3 == 0) && ($colcount < scalar(@mbr_fields))) $] [$ endif $] [$ endforeach $]
[+ $fontdef +] [+ $field +] [- $checked = ''; foreach $restriction (@restricted) { if ($restriction eq $field) { $checked = "checked"; } } -]
docs/index.html0100644000076700007730000000143007460122254013041 0ustar brettbrett Oak Hills 8th Ward
Welcome to the Oak Hills 8th ward website.

This is just a demo, and it lacks a pretty face. You'll need to use your imagination. The following links are examples of links that you'd see on the actual live site.

ward directory

events list

events calendar



This link wouldn't actually be on the site. It'd be a password protected area for use only by authorized people.

admin area
docs/events.epl0100644000076700007730000000316107257206105013057 0ustar brettbrett[- use lib('../lib'); use Ward; $escmode=0; -] [- @events = get_events('all'); %weekdays = ('sun' => 'Sunday', 'mon' => 'Monday', 'tue' => 'Tuesday', 'wed' => 'Wednesday', 'thu' => 'Thursday', 'fri' => 'Friday', 'sat' => 'Saturday'); -] OH8 - List Events

[- $fontdef = ''; -] Oak Hills 8th Ward Events List

[- $bgcolor = 'bgcolor=gray'; -] [- $bgcolor = 'bgcolor=white'; -] [$ foreach $ev (@events) $] [$ endforeach $]
[+ $fontdef +] Short Description [+ $fontdef +] When [+ $fontdef +] Where [+ $fontdef +] Contact
[+ $fontdef +] [+ $ev->get_link() +] [+ $fontdef +] [+ $ret = ''; if ($ev->{'recurring'} eq 'yes') { $ret = "every $weekdays{$ev->{'weekday'}}"; } else { $ret = $ev->{'date'} } $ret = ($ret eq '') ? ' ' : $ret; +] [+ $fontdef +] [+ $ev->{'location'} ne '' ? $ev->{'location'} : ' '; +] [+ $fontdef +] [+ my $mbr = get_member($ev->{'contact'}); $mbr->{'fname'} . ' ' . $mbr->{'lname'}; +]
docs/directory.epl0100644000076700007730000000235307460121233013553 0ustar brettbrett[- use lib('../lib'); use Ward; $escmode=0; -] [- @mbrs = get_members('all'); -] OH8 Ward Directory
[- $fontdef = ''; -] [- $bgcolor = 'bgcolor=white'; -] oak hills 8th ward directory

[+ $fontdef +]
[$ foreach $mbr (@mbrs) $] [$ endforeach $]
[+ $fontdef +] name [+ $fontdef +] address [+ $fontdef +] phone number [+ $fontdef +] e-mail
[+ $fontdef +] [+ $mbr->get_link() +] [+ $fontdef +] [+ $mbr->{'addr1'} . ' ' . $mbr->{'addr2'} +] [+ $fontdef +] [+ $mbr->{'phone'} +] [+ $fontdef +] [+ $mbr->{'email'} +]
home
docs/moreinfo/0040755000076700007730000000000007257211374012675 5ustar brettbrettdocs/moreinfo/member.epl0100644000076700007730000000115307257205630014641 0ustar brettbrett[- use lib('../../lib'); use Ward; $escmode=0; -] [- $mbr = get_member($fdat{mbr_id}); -] More Information: [+ $mbr->{fname} +] [+ $mbr->{lname} +]
[- $fontdef = ''; -] [- $bgcolor = 'bgcolor=white'; -] [$ foreach $field (sort keys %$mbr) $] [$ endforeach $]
[+ $fontdef +] [+ $field +] [+ $fontdef +] [+ $mbr->{$field} +]
docs/moreinfo/event.epl0100644000076700007730000000112107257205745014515 0ustar brettbrett[- use lib('../../lib'); use Ward; $escmode=0; -] [- $ev = get_event($fdat{ev_id}); -] More Information: [+ $ev->{sdesc} +]
[- $fontdef = ''; -] [- $bgcolor = 'bgcolor=white'; -] [$ foreach $field (sort keys %$ev) $] [$ endforeach $]
[+ $fontdef +] [+ $field +] [+ $fontdef +] [+ $ev->{$field} +]
docs/index.epl0100644000076700007730000000143707460122324012662 0ustar brettbrett[- use lib('../lib'); use Ward; $escmode=0; -] Welcome to OH8
Welcome to the Oak Hills 8th ward website.

This is just a demo, and it lacks a pretty face. You'll need to use your imagination. The following links are examples of links that you'd see on the actual live site.

ward directory

events list

events calendar



This link wouldn't actually be on the site. It'd be a password protected area for use only by authorized people.

admin area
lib/0040755000076700007730000000000007457624147010705 5ustar brettbrettlib/CONST.pm0100644000076700007730000000463207457126512012124 0ustar brettbrett# Contains those things that will only be used internally and never # accessed by the main epl templates, such as constants and internal # functions. May be used by admin area stuff and those modules called # by the main templates (such as Ward.pm), but not on the areas of # the site visible to the outside world. package CONST; use DBI qw(:sql_types); BEGIN { # (hopefully) used by every link on the site $embpcgi_loc = "/cgi-bin/embpcgi.pl"; # locations of templates for more info pages $mbr_epl = "/cgi-bin/embpcgi.pl/moreinfo/member.epl"; $ev_epl = "/cgi-bin/embpcgi.pl/moreinfo/event.epl"; $org_epl = "/cgi-bin/embpcgi.pl/moreinfo/org.epl"; # database connection stuff $dbd = "dbi:mysql:oh8"; $db = "oh8"; $dbpassword = "orknarp"; $dbh = DBI->connect($dbd, $db, $dbpassword) || die; # misc constants $dropdown_js = "/home/brett/oh8/web/tpl/dropdown_js.tpl"; $mailprog = "/usr/sbin/sendmail"; } #-----------------------------------------------------------------------------# sub get_dbh { return $dbh; } #-----------------------------------------------------------------------------# # Returns an array of current fields in the requested table in the database # in their proper order. sub get_fields { my $table = shift; my $sql = "describe $table"; my $sth = $dbh->prepare($sql); $sth->execute(); my @fields; while(@row = $sth->fetchrow_array()) { push(@fields, $row[0]); } $sth->finish(); return @fields; } #-----------------------------------------------------------------------------# # Returns a hash where each key is a field in the requested table in the # database and each value is the type to be used with that field in a DBI # bind_param operation. The only possible values are those returned by # SQL_INTEGER and SQL_VARCHAR, with the default being SQL_VARCHAR. sub get_fieldtypes { my $table = shift; my $sql = "describe $table"; my $sth = $dbh->prepare($sql); $sth->execute(); my @numtypes = ('tinyint', 'smallint', 'mediumint', 'int', 'integer', 'biginit', 'float', 'double', 'double precision', 'real', 'decimal', 'numeric'); my %fieldtypes; while(@row = $sth->fetchrow_array()) { my $type = SQL_VARCHAR; for (@numtypes) { if (lc($row[1]) =~ /$_/) { $type = SQL_INTEGER; } } $fieldtypes{$row[0]} = $type; } $sth->finish(); return %fieldtypes; } #-----------------------------------------------------------------------------# END { $dbh->disconnect(); } return 1; lib/Event.pm0100644000076700007730000000300107257203433012300 0ustar brettbrett# This class is a data structure representing one event. package Event; use strict; use CONST; #-----------------------------------------------------------------------------# # return an Event object with fields for each current field in the # events table in the database. each field is set to a blank string. sub new { my $self = {}; my @fields = CONST::get_fields('events'); foreach my $field (@fields) { $self->{$field} = ''; } bless($self); return $self; } #-----------------------------------------------------------------------------# # sets value of Event object fields. if value provided is undefined, field # will be set to an empty string. this prevents warning/error messages and # makes things generally easier. sub set { my $self = shift; my $field = shift; my $val = shift; $self->{$field} = (defined $val) ? $val : ''; } #-----------------------------------------------------------------------------# sub get_link { my $self = shift; my $ret = qq{}; $ret .= $self->{'sdesc'}; $ret .= qq{}; return $ret; } #-----------------------------------------------------------------------------# # returns an Event object which is an exact duplicate of the current one. sub copy { my $self = shift; my $new = Event->new(); foreach my $field (keys %$self) { $new->set($field, $self->{$field}); } return $new; } #-----------------------------------------------------------------------------# return 1; lib/Member.pm0100644000076700007730000000260207257203375012441 0ustar brettbrett# This class is a data structure representing one ward member. package Member; use strict; use CONST; use DBI; #-----------------------------------------------------------------------------# # return a Member object with fields for each field currenty in the # members table and each field currently in the addr table in the database. # each field is set to a blank string. sub new { my $self = {}; my @fields = CONST::get_fields('members'); foreach my $field (@fields) { $self->{$field} = ''; } @fields = CONST::get_fields('addr'); foreach my $field (@fields) { $self->{$field} = ''; } bless($self); return $self; } #-----------------------------------------------------------------------------# # sets value of Member object fields. if value provided is undefined, field # will be set to an empty string. this prevents warning/error messages and # makes things generally easier. sub set { my $self = shift; my $field = shift; my $val = shift; $self->{$field} = (defined $val) ? $val : ''; } #-----------------------------------------------------------------------------# sub get_link { my $self = shift; my $ret = qq{}; $ret .= $self->{'fname'} . " " . $self->{'lname'}; $ret .= qq{}; return $ret; } #-----------------------------------------------------------------------------# return 1; lib/Ward.pm0100644000076700007730000004640007457126563012140 0ustar brettbrettpackage Ward; use Exporter; @ISA = qw(Exporter); @EXPORT = qw(&get_member &get_members &get_blank_mbr &get_event &get_events &get_org &get_all_orgs &list_orgs &get_org_options &get_dropdown_js &get_mbr_ddopts &get_mbr_restricted &set_mbr_restricted &href); use Member; use Event; use Org; use Calling; use CONST; use Date::Calc; BEGIN { $dbh = CONST::get_dbh(); } #-----------------------------------------------------------------------------# # same as get_members, but for getting one Member object instead # of an array of Member objects sub get_member { my @members = get_members(@_); return $members[0]; } #-----------------------------------------------------------------------------# # returns array of Member objects. # if mbr_id passed, get only that member's data. # if single letter passed, get all whose last names start thus. # if field name and search criteria passed (separate args), run a search. # if org name passed, get all members with callings therein, sorted # according to call_rank in the callings table. # if person's name passed, get only that member's data. # if 'all' passed, get all members sub get_members { my ($sql, $sth, $srch); $srch = shift; if ($srch eq 'all') { $sql = "select * from members m, addr a where m.addr_id = a.addr_id and deleted = 'no'"; $sth = $dbh->prepare($sql); } elsif ($srch =~ /^\d+$/) { $sql = qq{SELECT * FROM members, addr WHERE mbr_id = ? AND members.addr_id = addr.addr_id}; $sth = $dbh->prepare($sql); $sth->bind_param(1, $srch); } elsif ($srch =~ /^\w$/) { $srch .= "%"; $sql = qq{SELECT * FROM members, addr WHERE lname LIKE ? AND members.addr_id = addr.addr_id ORDER BY lname, fname}; $sth = $dbh->prepare($sql); $sth->bind_param(1, $srch); } elsif ($#_ > 0) { my $srchfield = shift; $srch = "%" . $srch . "%"; $sql = qq{SELECT * FROM members, addr WHERE $srchfield LIKE ? AND members.addr_id = addr.addr_id ORDER BY lname, fname}; $sth = $dbh->prepare($sql); $sth->bind_param(1, $srch); } elsif ($srch =~ /^\w+(\s*\w*)*$/) { $sql = qq{SELECT org_id from org WHERE org_name=? OR org_nickname=?}; $sth = $dbh->prepare($sql); $sth->bind_param(1, $srch); $sth->bind_param(2, $srch); $sth->execute(); my ($org_id) = $sth->fetchrow_arrayref(); if (defined $org_id) { # gotta fix this later. probably just kill this part cause it's now # redunant with get_org(). # $sql = qq{SELECT * from orgstaff, org, callings, members # WHERE org.org_id = $org_id # AND orgstaff.org_id = org.org_id # AND callings.call_id = orgstaff.call_id # AND members.mbr_id = orgstaff.mbr_id # ORDER BY callings.call_rank DESC}; # $sth = $dbh->prepare($sql); } else { my ($fname, $lname) = ($srch =~ /^(\w+)\s(\w+)$/); $sql = qq{SELECT mbr_id from members WHERE fname=? AND lname=?}; $sth = $dbh->prepare($sql); $sth->bind_param(1, $fname); $sth->bind_param(2, $lname); $sth->execute(); my $mbr_id = $sth->fetchrow_arrayref(); if (defined $mbr_id->[0]) { $mbr_id = $mbr_id->[0]; $sql = "SELECT * from members WHERE mbr_id=?"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $mbr_id); } } } else { return; } # run the query, set up array of Member objects to return $sth->execute(); my @mbr_arr = (); while (my $rowhash = $sth->fetchrow_hashref()) { my $mbrtmp = Member->new(); foreach my $key (keys %$rowhash) { $mbrtmp->set($key => $rowhash->{$key}); } # suppress restricted fields my @restricted = get_mbr_restricted($mbrtmp->{mbr_id}); foreach $restriction (@restricted) { $mbrtmp->set($restriction, ''); } push(@mbr_arr, $mbrtmp); } $sth->finish(); return @mbr_arr; } #-----------------------------------------------------------------------------# # Accepts a mbr_id and returns an array of the restricted fields for that # member. These are stored in the 'restricted' column as a comma-delimited # string and are those fields which should not be shown on the site as per # the member's request. sub get_mbr_restricted { my $mbr_id = shift; my $sql = "select restricted from members where mbr_id = ?"; my $sth = $dbh->prepare($sql); $sth->bind_param(1, $mbr_id); $sth->execute(); my ($fields) = $sth->fetchrow_array(); my @restricted = split(',', $fields); $sth->finish(); return @restricted; } #-----------------------------------------------------------------------------# # Accepts a mbr_id and an an arrayref of fields to be set as restricted. sub set_mbr_restricted { my $mbr_id = shift; my $restricted = shift; my $fields = join(',', @$restricted); my $sql = "update members set restricted = ? where mbr_id = ?"; my $sth = $dbh->prepare($sql); $sth->bind_param(1, $fields); $sth->bind_param(2, $mbr_id); $sth->execute(); $sth->finish(); } #-----------------------------------------------------------------------------# # same as get_events, but for getting one Event object instead # of an array of Event objects sub get_event { my @events = get_events(@_); return $events[0]; } #-----------------------------------------------------------------------------# # if ev_id passed, get only that event's data. # if 'all' passed, get all events where deleted=no # if date range passed, get events within that range. (not done yet) # if weekday passed, get recurring events on that weekday. # if month and year passed, get events in that month. sub get_events { my ($sql, $sth, $srch, $month, $year, $no_setup, %months, %weekdays); $srch = lc(shift); %months = ('january' => 1, 'february' => 2, 'march' => 3, 'april' => 4, 'may' => 5, 'june' => 6, 'july' => 7, 'august' => 8, 'september' => 9, 'october' => 10, 'november' => 11, 'december' => 12); %weekdays = ('sunday' => 'sun', 'monday' => 'mon', 'tuesday' => 'tue', 'wednesday' => 'wed', 'thursday' => 'thu', 'friday' => 'fri', 'saturday' => 'sat'); if (join(' ', keys %months) =~ /$srch/) { $month = $srch; $year = shift; if (! defined $year) { die "you must specify a year when using get_events() with a month"; } $no_setup = shift; } if ($srch eq 'all') { $sql = "SELECT * FROM events WHERE deleted='no' order by ev_id desc"; $sth = $dbh->prepare($sql); } elsif ($srch =~ /^\d+$/) { $sql = "SELECT * FROM events WHERE ev_id=?"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $srch); } elsif (defined $weekdays{$srch}) { $sql = "SELECT * FROM events WHERE recurring='yes' AND weekday=? and deleted='no'"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $weekdays{$srch}); } elsif (defined $month) { $sql = "SELECT * FROM events WHERE ((MONTH(date)=? AND YEAR(date)=?) or (recurring='yes')) and deleted='no'"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $months{$month}); $sth->bind_param(2, $year); } else { return; } # run the query, set up array of Event objects to return. # this includes getting Member object for each event's contact person. $sth->execute(); my @ev_arr = (); while (my $rowhash = $sth->fetchrow_hashref()) { my $evtmp = Event->new(); foreach my $key (keys %$rowhash) { $evtmp->set($key => $rowhash->{$key}); } push(@ev_arr, $evtmp); } $sth->finish(); # if a month was passed, set up the array for that month, unless the string # 'no_setup' was also passed. if (defined $month) { if ((defined $no_setup) && ($no_setup eq 'no_setup')) { # skip over the month setup stuff } else { my $month_num = Date::Calc::Decode_Month($month); if (length($month_num) == 1) { $month_num = '0' . $month_num; } @ev_arr = setup_month_events($month_num, $year, \@ev_arr); } } return @ev_arr; } #-----------------------------------------------------------------------------# # Accepts a numerical month, a year, and an arrayref of Event objects. Returns # an array of Event objects set up to use in the context of a calendar for the # given month. There will be one copy of each recurring event for each relevant # weekday in the month, unless that week has an exception, in which case that # exception will take its place. Any additional exceptions will also be # included. sub setup_month_events { my @ret; my ($month, $year, $ev_arrayref) = @_; my @ev_arr = @$ev_arrayref; my $days_in_month = Date::Calc::Days_in_Month($year, $month); my $first_weekday = Date::Calc::Day_of_Week($year, $month, 1); # set up an array of dates of first days of each week in the given month. # this will be the first day of the month plus all Sundays. my $sunday = 8 - $first_weekday; my @wk_first_days = (1); foreach (1..5) { if ($sunday > $days_in_month) { last; } push(@wk_first_days, $sunday); $sunday += 7; } # include all one-time events and exceptions. foreach my $ev (@ev_arr) { if (($ev->{'recurring'} eq 'no') || ($ev->{'exception_to'} ne '')) { push(@ret, $ev); } } # loop over the array of first days. if any recurring event has any # exceptions whose date falls within the period from a wk_first_day to the # following Saturday, include the exceptions instead of the recurring event. # otherwise, create a copy of the recurring event on its set weekday. my $til_saturday; if ($first_weekday == 7) { $til_saturday = 6; } else { $til_saturday = 6 - $first_weekday; } foreach my $wk_first_day (@wk_first_days) { if ($wk_first_day != 1) { $til_saturday = 6; } foreach my $ev (@ev_arr) { if (($ev->{'recurring'} eq 'no') || ($ev->{'exception_to'} ne '')) { next; } # only recurring events get this far. # check for exceptions in current week. my $include = 1; foreach my $possible_exception (@ev_arr) { if ($possible_exception->{'exception_to'} ne $ev->{'ev_id'}) { next; } my $date = $possible_exception->{'date'}; my ($y, $m, $d) = ($date =~ /(\d{4})-(\d{2})-(\d{2})/); if (($d >= $wk_first_day) && ($d <= $wk_first_day + $til_saturday)) { $include = 0; } } # if no exceptions found, make a copy of the current recurring event and # set its date to the date of that event's normal weekday for the current # week. if ($include) { my $wkday = Date::Calc::Decode_Day_of_Week($ev->{'weekday'}); my $day; if ($wk_first_day == 1) { $day = $wkday - $til_saturday + 1; } else { $day = $wk_first_day + $wkday; } if (($day > $days_in_month) || ($day < 1)) { next; } if (length($day) == 1) { $day = '0' . $day; } my $recur_date = $year . '-' . $month . '-' . $day; my $recurring = $ev->copy(); $recurring->set('date', $recur_date); push(@ret, $recurring); } } } return @ret; } #-----------------------------------------------------------------------------# # Accepts a nickname, name, or org_id of an existing organization in the org # table in the database and returns an Org object for the requested # organization. The Org object contains fields for org_id, org_name, and # org_nickname as well as a reference to an array of Calling objects which are # the possible positions to be held within the organization. It also usually # contains references to arrays of Member objects for the staff and the # membership of that organization. The 'staff' is the members of that # organization that have callings in it. The 'membership' is the members of the # organization that do not have callings in it. For example, many women are # members of the Relief Society but have callings in some other organization; # these would be members, not staff. Relief Society President or Relief Society # pianist are staff (as well as members). The staff and members fields will not # be populated if 'no_members' is passed as a second argument. sub get_org { my ($sql, $sth, $rowhash, $mbrtmp); my $req = shift; $sql = "select * from org where org_nickname = ? or org_name = ? or org_id = ?"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $req, 1); $sth->bind_param(2, $req, 1); $sth->bind_param(3, $req, 0); $sth->execute(); $rowhash = $sth->fetchrow_hashref(); my $org = Org->new(); foreach my $field (keys %$rowhash) { $org->set($field => $rowhash->{$field}); } my $org_id = $org->{'org_id'}; # get callings of organization $sql = "SELECT * from callings where org_id = ? order by call_rank desc"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $org_id, 0); $sth->execute(); my @callings; my $calltmp; while ($rowhash = $sth->fetchrow_hashref()) { $calltmp = Calling->new(); foreach my $key (keys %$rowhash) { $calltmp->set($key => $rowhash->{$key}); } push(@callings, $calltmp); } $org->{'callings'} = \@callings; if ((defined $no_mbrs) && ($no_mbrs eq 'no_members')) { return $org; } # get staff of organization $sql = "SELECT m.*, c.*, mc.setapart from members m, callings c, mbrcallings mc WHERE c.org_id = ? AND c.call_id = mc.call_id AND m.mbr_id = mc.mbr_id ORDER BY c.call_rank DESC, mc.setapart"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $org_id, 0); $sth->execute(); my @staff; while ($rowhash = $sth->fetchrow_hashref()) { $mbrtmp = Member->new(); foreach my $key (keys %$rowhash) { $mbrtmp->set($key => $rowhash->{$key}); } push(@staff, $mbrtmp); } $org->{'staff'} = \@staff; # get members of organization $sql = "SELECT m.* from orgmbr om, org o, members m WHERE o.org_id = ? AND om.org_id = o.org_id AND m.mbr_id = om.mbr_id"; $sth = $dbh->prepare($sql); $sth->bind_param(1, $org_id, 0); $sth->execute(); my @mbrs; while ($rowhash = $sth->fetchrow_hashref()) { $mbrtmp = Member->new(); foreach my $key (keys %$rowhash) { $mbrtmp->set($key => $rowhash->{$key}); } push(@mbrs, $mbrtmp); } $org->{'members'} = \@mbrs; return $org; } #-----------------------------------------------------------------------------# # Returns an anonymous hash of Org objects representing all entries in the org # table in the database. Member data not summoned if 'no_members' is passed. sub get_all_orgs { my ($sql, $sth, $org_id); my $no_mbrs = shift; $sql = "select org_id from org"; $sth = $dbh->prepare($sql); $sth->execute(); my $orgs = {}; my $orgtmp = {}; while (($org_id) = $sth->fetchrow_array()) { if ((defined $no_mbrs) && ($no_mbrs eq 'no_members')) { $orgtmp = get_org($org_id, 'no_members'); $orgs->{$orgtmp->{'org_name'}} = $orgtmp; } else { $orgtmp = get_org($org_id); $orgs->{$orgtmp->{'org_name'}} = $orgtmp; } } return $orgs; } #-----------------------------------------------------------------------------# # Returns an array of org_names in the order they appear in the database. sub list_orgs { my ($sql, $sth); $sql = "select org_name from org"; $sth = $dbh->prepare($sql); $sth->execute(); my @orgs; while (($org_name) = $sth->fetchrow_array()) { push(@orgs, $org_name); } return @orgs; } #-----------------------------------------------------------------------------# # Accepts an optional org_id and returns an html dropdown of all the orgs in # the database. If the org_id is specified, that option will be selected. sub get_org_options { my $selorg = shift; my $retval = ''; my @orglist = list_orgs(); my $orgs = get_all_orgs('no_members'); my $sel; foreach my $org (@orglist) { $org = $orgs->{$org}; $sel = ((defined $selorg) && ($org->{'org_id'} eq $selorg)) ? 'selected' : ''; $retval .= qq|