Skip to content

Commit

Permalink
Merge pull request #323 from chris18890/cleanup
Browse files Browse the repository at this point in the history
code cleanup #253 #281 #319 #320 #321
  • Loading branch information
elplatt committed Dec 26, 2015
2 parents df12175 + bc875cf commit d0e2316
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 67 deletions.
1 change: 1 addition & 0 deletions crm/autocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// Save path of directory containing index.php
$crm_root = dirname(__FILE__);

// Bootstrap the site
include('include/crm.inc.php');

$handler = $_GET['command'] . '_autocomplete';
Expand Down
3 changes: 2 additions & 1 deletion crm/export-csv.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand All @@ -22,7 +23,7 @@
// Save path of directory containing index.php
$crm_root = dirname(__FILE__);

// Bootstrap the crm
// Bootstrap the site
require_once('include/crm.inc.php');

header('Content-type: text/csv');
Expand Down
2 changes: 1 addition & 1 deletion crm/include/crm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

// Optional Modules ////////////////////////////////////////////////////////////
foreach ($config_modules as $module) {
require_once($crm_root. '/modules/' . $module . '/' . $module . '.inc.php');
require_once($crm_root . '/modules/' . $module . '/' . $module . '.inc.php');
}

// Initialize //////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions crm/include/sys/command.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion crm/include/sys/data.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions crm/include/sys/error.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions crm/include/sys/module.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion crm/include/sys/util.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down Expand Up @@ -96,7 +97,7 @@ function crm_error ($text) {
}

/**
* Parse and return the version of the CRM as specified in crm.inc.php under £crm_version.
* Parse and return the version of the CRM as specified in crm.inc.php under $crm_version.
* @return A string representation of the array
*/
function crm_version() {
Expand Down
2 changes: 1 addition & 1 deletion crm/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Save path of directory containing index.php
$crm_root = dirname(__FILE__);

// Bootstrap the crm
// Bootstrap the site
require_once('include/crm.inc.php');

// Check for GET/POST command
Expand Down
2 changes: 1 addition & 1 deletion crm/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Save path of directory containing index.php
$crm_root = dirname(__FILE__);

// Bootstrap the crm
// Bootstrap the site
require_once('include/crm.inc.php');

$template_vars = array('path' => 'install');
Expand Down
2 changes: 1 addition & 1 deletion crm/modules/billing/billing.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function billing_page (&$page_data, $page_name, $options) {
// Add view and add tabs
if (user_access('payment_edit')) {
page_add_content_top($page_data, theme('form', crm_get_form('billing')), 'Billing');
page_add_content_top($page_data, theme('form', crm_get_form('email_bills')), 'Billing');
page_add_content_bottom($page_data, theme('form', crm_get_form('email_bills')), 'Billing');
}
break;
case 'contact':
Expand Down
33 changes: 20 additions & 13 deletions crm/modules/contact/contact.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down Expand Up @@ -144,22 +144,23 @@ function contact_data ($opts = array()) {
}
}
$sql .= "
ORDER BY `lastName`, `firstName`, `middleName` ASC";
ORDER BY `lastName`, `firstName`, `middleName` ASC
";
$res = mysql_query($sql);
if (!$res) crm_error(mysql_error());
// Store data
$contacts = array();
$row = mysql_fetch_assoc($res);
while (!empty($row)) {
$contacts[] = array(
'cid' => $row['cid'],
'firstName' => $row['firstName'],
'middleName' => $row['middleName'],
'lastName' => $row['lastName'],
'email' => $row['email'],
'phone' => $row['phone'],
'emergencyName' => $row['emergencyName'],
'emergencyPhone' => $row['emergencyPhone']
'cid' => $row['cid']
, 'firstName' => $row['firstName']
, 'middleName' => $row['middleName']
, 'lastName' => $row['lastName']
, 'email' => $row['email']
, 'phone' => $row['phone']
, 'emergencyName' => $row['emergencyName']
, 'emergencyPhone' => $row['emergencyPhone']
);
$row = mysql_fetch_assoc($res);
}
Expand All @@ -171,7 +172,9 @@ function contact_data ($opts = array()) {
* Saves a contact.
*/
function contact_save ($contact) {
$fields = array('cid', 'firstName', 'middleName', 'lastName', 'email', 'phone', 'emergencyName', 'emergencyPhone');
$fields = array(
'cid', 'firstName', 'middleName', 'lastName', 'email', 'phone', 'emergencyName', 'emergencyPhone'
);
$escaped = array();
foreach ($fields as $field) {
$escaped[$field] = mysql_real_escape_string($contact[$field]);
Expand Down Expand Up @@ -201,7 +204,8 @@ function contact_save ($contact) {
INSERT INTO `contact`
(`firstName`,`middleName`,`lastName`,`email`,`phone`,`emergencyName`,`emergencyPhone`)
VALUES
('$escaped[firstName]','$escaped[middleName]','$escaped[lastName]','$escaped[email]','$escaped[phone]','$escaped[emergencyName]','$escaped[emergencyPhone]')";
('$escaped[firstName]','$escaped[middleName]','$escaped[lastName]','$escaped[email]','$escaped[phone]','$escaped[emergencyName]','$escaped[emergencyPhone]')
";
$res = mysql_query($sql);
if (!$res) crm_error(mysql_error());
$contact['cid'] = mysql_insert_id();
Expand Down Expand Up @@ -586,7 +590,10 @@ function contact_page (&$page_data, $page_name) {
if (user_access('contact_view')) {
$opts = array(
'show_export'=>true
, 'exclude'=>array('emergencyName', 'emergencyPhone')
, 'exclude'=>array(
'emergencyName',
'emergencyPhone'
)
);
$view = theme('table', crm_get_table('contact', $opts));
page_add_content_top($page_data, $view, 'View');
Expand Down
14 changes: 3 additions & 11 deletions crm/modules/member/command.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down Expand Up @@ -94,9 +94,6 @@ function command_member_add () {
);
$member = array('membership' => $membership);
$contact['member'] = $member;
// Add user fields
$user = array('username' => $username);
$contact['user'] = $user;
// Save to database
$contact = contact_save($contact);

Expand Down Expand Up @@ -213,8 +210,6 @@ function command_member_membership_add () {
return crm_url('members');
}

// Add membership

// Construct membership object and save
$membership = array(
'sid' => $_POST['sid']
Expand All @@ -225,7 +220,7 @@ function command_member_membership_add () {
);
member_membership_save($membership);

return crm_url("contact&cid=$_POST[cid]");
return crm_url("contact&cid=$_POST[cid]&tab=plan");
}

/**
Expand Down Expand Up @@ -275,7 +270,7 @@ function command_member_membership_delete () {
// Delete membership
member_membership_delete($esc_post['sid']);

return crm_url("contact&cid=$_POST[cid]");
return crm_url("contact&cid=$_POST[cid]&tab=plan");
}

/**
Expand Down Expand Up @@ -431,9 +426,6 @@ function command_member_import () {
);
$member = array('membership' => $membership);
$contact['member'] = $member;
// Add user
$user = array('username' => $username);
$contact['user'] = $user;

$contact = contact_save($contact);

Expand Down
23 changes: 12 additions & 11 deletions crm/modules/member/data.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down Expand Up @@ -82,14 +82,14 @@ function member_data ($opts = array()) {
$member = array(
'cid' => $row['cid'],
'contact' => array(
'cid' => $row['cid'],
'firstName' => $row['firstName'],
'middleName' => $row['middleName'],
'lastName' => $row['lastName'],
'email' => $row['email'],
'phone' => $row['phone'],
'emergencyName' => $row['emergencyName'],
'emergencyPhone' => $row['emergencyPhone']
'cid' => $row['cid']
, 'firstName' => $row['firstName']
, 'middleName' => $row['middleName']
, 'lastName' => $row['lastName']
, 'email' => $row['email']
, 'phone' => $row['phone']
, 'emergencyName' => $row['emergencyName']
, 'emergencyPhone' => $row['emergencyPhone']
),
'user' => array(
'cid' => $row['cid'],
Expand Down Expand Up @@ -228,7 +228,8 @@ function member_contact_api ($contact, $op) {
INSERT INTO `user_role`
(`cid`, `rid`)
VALUES
('$esc_cid', '$esc_rid')";
('$esc_cid', '$esc_rid')
";
$res = mysql_query($sql);
if (!$res) crm_error(mysql_error());
}
Expand Down Expand Up @@ -310,7 +311,7 @@ function member_plan_data ($opts = array()) {

/**
* Generates an associative array mapping membership plan pids to
* strings describing those membership plan.
* strings describing those membership plans.
*
* @param $opts Options to be passed to member_plan_data().
* @return The associative array of membership plan descriptions.
Expand Down
30 changes: 26 additions & 4 deletions crm/modules/member/form.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down Expand Up @@ -262,6 +262,9 @@ function member_membership_add_form ($cid) {
return NULL;
}

// Generate default start date, first of current month
$start = date("Y-m-d");

// Create form structure
$form = array(
'type' => 'form',
Expand All @@ -285,7 +288,8 @@ function member_membership_add_form ($cid) {
'type' => 'text',
'label' => 'Start',
'name' => 'start',
'class' => 'date'
'class' => 'date',
'value' => $start
),
array(
'type' => 'text',
Expand Down Expand Up @@ -510,7 +514,19 @@ function member_import_form () {
, 'fields' => array(
array(
'type' => 'message'
, 'value' => '<p>To import members, upload a csv. The csv should have a header row with the following fields:</p><ul><li>First Name</li><li>Middle Name</li><li>Last Name</li><li>Email</li><li>Phone</li><li>Emergency Name</li><li>Emergency Phone</li><li>Username</li><li>Plan</li><li>Start Date</li></ul>'
, 'value' => '<p>To import members, upload a csv. The csv should have a header row with the following fields:</p>
<ul>
<li>First Name</li>
<li>Middle Name</li>
<li>Last Name</li>
<li>Email</li>
<li>Phone</li>
<li>Emergency Name</li>
<li>Emergency Phone</li>
<li>Username</li>
<li>Plan</li>
<li>Start Date</li>
</ul>'
)
, array(
'type' => 'file'
Expand All @@ -537,7 +553,13 @@ function plan_import_form () {
, 'fields' => array(
array(
'type' => 'message'
, 'value' => '<p>To import plans, upload a csv. The csv should have a header row with the following fields:</p><ul><li>Plan Name</li><li>Price</li><li>Active (Set to 1/0 signalling Y/N)</li><li>Voting (Set to 1/0 signalling Y/N)</li></ul>'
, 'value' => '<p>To import plans, upload a csv. The csv should have a header row with the following fields:</p>
<ul>
<li>Plan Name</li>
<li>Price</li>
<li>Active (Set to 1/0 signalling Y/N)</li>
<li>Voting (Set to 1/0 signalling Y/N)</li>
</ul>'
)
, array(
'type' => 'file'
Expand Down
2 changes: 1 addition & 1 deletion crm/modules/member/install.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion crm/modules/member/member.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down
7 changes: 5 additions & 2 deletions crm/modules/member/page.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down Expand Up @@ -60,7 +60,10 @@ function member_page (&$page_data, $page_name, $options) {
$opts = array(
'filter'=>$_SESSION['member_filter']
, 'show_export'=>true
, 'exclude'=>array('emergencyName', 'emergencyPhone')
, 'exclude'=>array(
'emergencyName',
'emergencyPhone'
)
);
$view .= theme('table', crm_get_table('member', $opts));
page_add_content_top($page_data, $view, 'View');
Expand Down
14 changes: 7 additions & 7 deletions crm/modules/member/table.inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

/*
Copyright 2009-2014 Edward L. Platt <[email protected]>
Expand Down Expand Up @@ -177,7 +177,7 @@ function member_voting_report_table () {
$table['columns'][] = array('title'=>'D','class'=>'');
$table['columns'][] = array('title'=>'E','class'=>'');
}

// Loop through member data
foreach ($members as $member) {

Expand Down Expand Up @@ -370,11 +370,11 @@ function member_contact_table ($opts) {

// Add row
$table['rows'][] = array(
theme('contact_name', $contact),
$contact['email'],
$contact['phone'],
$contact['emergencyName'],
$contact['emergencyPhone']
theme('contact_name', $contact)
, $contact['email']
, $contact['phone']
, $contact['emergencyName']
, $contact['emergencyPhone']
);

return $table;
Expand Down
Loading

0 comments on commit d0e2316

Please sign in to comment.