Skip to content

Commit

Permalink
Merge pull request #477 from elplatt/dev
Browse files Browse the repository at this point in the history
release v0.7.2
  • Loading branch information
chris18890 committed Feb 27, 2021
2 parents 018f4ea + e3d50a7 commit e6990f2
Show file tree
Hide file tree
Showing 23 changed files with 449 additions and 133 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
Seltzer CRM 0.6.6 - An open source CRM for hackerspaces
Seltzer CRM 0.7.2 - An open source CRM for hackerspaces
Copyright 2009-2021 Edward L. Platt <ed@elplatt.com>
Distributed under GPLv3 (see COPYING for more info)

Expand Down
1 change: 1 addition & 0 deletions crm/config.sample.inc.php
Expand Up @@ -133,5 +133,6 @@
, 'email_lists' => 'Email Lists'
, 'reports' => 'Reports'
, 'permissions' => 'Permissions'
, 'global_options' => 'Global Options'
, 'upgrade' => 'Upgrade'
);
4 changes: 2 additions & 2 deletions crm/include/crm.inc.php
Expand Up @@ -23,8 +23,8 @@
// Configuration ///////////////////////////////////////////////////////////////
$crm_version = array(
'major' => 0
, 'minor' => 6
, 'patch' => 6
, 'minor' => 7
, 'patch' => 2
, 'revision' => 'dev'
);
require_once($crm_root . '/config.inc.php');
Expand Down
9 changes: 9 additions & 0 deletions crm/include/page.inc.php
Expand Up @@ -38,6 +38,9 @@ function core_page_list () {
if (user_access('user_permissions_edit')) {
$pages[] = 'permissions';
}
if (user_access('global_options_view')) {
$pages[] = 'global_options';
}
if (user_access('module_upgrade')) {
$pages[] = 'upgrade';
}
Expand Down Expand Up @@ -94,6 +97,12 @@ function core_page (&$page_data, $page_name, $options) {
page_add_content_top($page_data, theme('form', crm_get_form('user_permissions')));
}
break;
case 'global_options':
if (user_access('global_options_view')) {
page_set_title($page_data, 'Global Options');
page_add_content_top($page_data, theme('form', crm_get_form('global_options')));
}
break;
case 'upgrade':
if (user_access('module_upgrade')) {
page_set_title($page_data, 'Upgrade Modules');
Expand Down
68 changes: 35 additions & 33 deletions crm/include/sys/module.inc.php
Expand Up @@ -122,6 +122,8 @@ function module_core_installed () {
* Installs all configured modules.
*/
function module_install () {
global $db_connect;
global $esc_post;
// Check whether already installed
if (module_core_installed()) {
error_register('The database must be empty before you can install ' . title() . " " . crm_version() . '!');
Expand All @@ -137,6 +139,39 @@ function module_install () {
$revision = module_get_code_revision($module);
module_set_schema_revision($module, $revision);
}
// Add admin contact and user
$sql = "
INSERT INTO `contact`
(`firstName`, `lastName`, `email`)
VALUES
('Admin', 'User', '$esc_post[email]')
";
$res = mysqli_query($db_connect, $sql);
if (!$res) die(mysqli_error($res));
$cid = mysqli_insert_id($db_connect);
$esc_cid = mysqli_real_escape_string($db_connect, $cid);
$esc_date = mysqli_real_escape_string($db_connect, date("Y-m-d"));
$esc_time = mysqli_real_escape_string($db_connect, date("H:i:s", time()));
$sql = "
UPDATE `contact`
SET `createdBy`='$esc_cid'
, `createdDate`='$esc_date'
, `createdTime`='$esc_time'
WHERE `cid`='$esc_cid'
";
$res = mysqli_query($db_connect, $sql);
if (!$res) die(mysqli_error($res));
$salt = user_salt();
$esc_hash = mysqli_real_escape_string($db_connect, user_hash($_POST['password'], $salt));
$esc_salt = mysqli_real_escape_string($db_connect, $salt);
$sql = "
INSERT INTO `user`
(`cid`, `username`, `hash`, `salt`)
VALUES
('$esc_cid', 'admin', '$esc_hash', '$esc_salt')
";
$res = mysqli_query($db_connect, $sql);
if (!$res) die(mysqli_error($res));
return true;
}

Expand Down Expand Up @@ -272,39 +307,6 @@ function command_module_install () {
if (!$res) {
return crm_url();
}
// Add admin contact and user
$sql = "
INSERT INTO `contact`
(`firstName`, `lastName`, `email`)
VALUES
('Admin', 'User', '$esc_post[email]')
";
$res = mysqli_query($db_connect, $sql);
if (!$res) die(mysqli_error($res));
$cid = mysqli_insert_id($db_connect);
$esc_cid = mysqli_real_escape_string($db_connect, $cid);
$esc_date = mysqli_real_escape_string($db_connect, date("Y-m-d"));
$esc_time = mysqli_real_escape_string($db_connect, date("H:i:s", time()));
$sql = "
UPDATE `contact`
SET `createdBy`='$esc_cid'
, `createdDate`='$esc_date'
, `createdTime`='$esc_time'
WHERE `cid`='$esc_cid'
";
$res = mysqli_query($db_connect, $sql);
if (!$res) die(mysqli_error($res));
$salt = user_salt();
$esc_hash = mysqli_real_escape_string($db_connect, user_hash($_POST['password'], $salt));
$esc_salt = mysqli_real_escape_string($db_connect, $salt);
$sql = "
INSERT INTO `user`
(`cid`, `username`, `hash`, `salt`)
VALUES
('$esc_cid', 'admin', '$esc_hash', '$esc_salt')
";
$res = mysqli_query($db_connect, $sql);
if (!$res) die(mysqli_error($res));
message_register(title() . " " . crm_version() . ' has been installed.');
message_register('You may log in as user "admin"');
return crm_url('login');
Expand Down
2 changes: 1 addition & 1 deletion crm/include/sys/table.inc.php
Expand Up @@ -184,7 +184,7 @@ function theme_table_csv ($table_name, $opts = null) {
* @return The escaped string.
*/
function table_escape_csv ($cell) {
return '"' . str_replace('"', '\"', $cell) . '"';
return '"' . str_replace('"', '\"', $cell) . '"';
}

/**
Expand Down
10 changes: 3 additions & 7 deletions crm/include/sys/template.inc.php
Expand Up @@ -56,12 +56,10 @@ function template_render ($name, $vars = array()) {
* @param $vars The previously set variables.
*/
function template_preprocess ($vars) {
global $config_org_name;
global $config_base_path;
$vars['title'] = title();
$vars['org_name'] = $config_org_name;
$vars['base_path'] = $config_base_path;
$vars['hostname'] = $_SERVER['SERVER_NAME'];
$vars['org_name'] = get_org_name();
$vars['base_path'] = base_path();
$vars['hostname'] = get_host();
return $vars;
}

Expand All @@ -70,8 +68,6 @@ function template_preprocess ($vars) {
* @param $vars The previously set variables.
*/
function template_preprocess_page ($vars) {
global $config_org_name;
global $config_base_path;
$vars['scripts'] = theme('scripts');
$vars['stylesheets'] = theme('stylesheets');
$vars['header'] = theme('header');
Expand Down
7 changes: 3 additions & 4 deletions crm/include/sys/theme.inc.php
Expand Up @@ -24,17 +24,16 @@
* @return the path to the theme folder without leading or trailing slashes.
*/
function path_to_theme() {
global $config_theme;
if (strlen($config_theme) > 0) {
return "themes/$config_theme";
if (strlen(get_theme()) > 0) {
return "themes/" . get_theme();
} else {
return 'themes/inspire';
}
}

/**
* Map theme calls to appropriate theme handler.
* At least one parmaeter is required, namely the element being themed.
* At least one parameter is required, namely the element being themed.
* Additional parameters will be passed on to the theme handler.
* @param $element The element to theme.
* @return The themed html string for the specified element.
Expand Down
123 changes: 118 additions & 5 deletions crm/include/sys/util.inc.php
Expand Up @@ -25,7 +25,8 @@
*/
function base_path () {
global $config_base_path;
return $config_base_path;
$variable_base_path = variable_get('base_path', $config_base_path);
return $variable_base_path;
}

/**
Expand All @@ -40,7 +41,8 @@ function path () {
*/
function title () {
global $config_site_title;
return $config_site_title;
$variable_site_title = variable_get('site_title', $config_site_title);
return $variable_site_title;
}

/**
Expand Down Expand Up @@ -111,21 +113,132 @@ function crm_version() {
*/
function github_username () {
global $config_github_username;
return $config_github_username;
$variable_github_username = variable_get('github_username', $config_github_username);
return $variable_github_username;
}

/**
* @return The github username configured in config.inc.php to display in the footer.
*/
function github_repo () {
global $config_github_repo;
return $config_github_repo;
$variable_github_repo = variable_get('github_repo', $config_github_repo);
return $variable_github_repo;
}

/**
* @return The URL protocol configured in config.inc.php for use in outgoing emails.
*/
function protocol_security () {
global $config_protocol_security;
return $config_protocol_security;
$variable_protocol_security = variable_get('protocol_security', $config_protocol_security);
return $variable_protocol_security;
}

/**
* @return The hostname configured in config.inc.php.
*/
function get_host () {
global $config_host;
$variable_host = variable_get('host', $config_host);
return $variable_host;
}

/**
* @return The org name configured in config.inc.php.
*/
function get_org_name () {
global $config_org_name;
$variable_org_name = variable_get('org_name', $config_org_name);
return $variable_org_name;
}

/**
* @return The org website configured in config.inc.php.
*/
function get_org_website () {
global $config_org_website;
$variable_org_website = variable_get('org_website', $config_org_website);
return $variable_org_website;
}

/**
* @return The currency code configured in config.inc.php.
*/
function get_currency_code () {
global $config_currency_code;
$variable_currency_code = variable_get('currency_code', $config_currency_code);
return $variable_currency_code;
}

/**
* @return The email from configured in config.inc.php.
*/
function get_email_from () {
global $config_email_from;
$variable_email_from = variable_get('email_from', $config_email_from);
return $variable_email_from;
}

/**
* @return The email to configured in config.inc.php.
*/
function get_email_to () {
global $config_email_to;
$variable_email_to = variable_get('email_to', $config_email_to);
return $variable_email_to;
}

/**
* @return The address1 configured in config.inc.php.
*/
function get_address1 () {
global $config_address1;
$variable_address1 = variable_get('address1', $config_address1);
return $variable_address1;
}

/**
* @return The address2 configured in config.inc.php.
*/
function get_address2 () {
global $config_address2;
$variable_address2 = variable_get('address2', $config_address2);
return $variable_address2;
}

/**
* @return The address3 configured in config.inc.php.
*/
function get_address3 () {
global $config_address3;
$variable_address3 = variable_get('address3', $config_address3);
return $variable_address3;
}

/**
* @return The town/city configured in config.inc.php.
*/
function get_town_city () {
global $config_town_city;
$variable_town_city = variable_get('town_city', $config_town_city);
return $variable_town_city;
}

/**
* @return The zipcode configured in config.inc.php.
*/
function get_zipcode () {
global $config_zipcode;
$variable_zipcode = variable_get('zipcode', $config_zipcode);
return $variable_zipcode;
}

/**
* @return The theme configured in config.inc.php.
*/
function get_theme () {
global $config_theme;
$variable_theme = variable_get('theme', $config_theme);
return $variable_theme;
}
8 changes: 3 additions & 5 deletions crm/modules/amazon_payment/amazon_payment.inc.php
Expand Up @@ -636,8 +636,6 @@ function theme_amazon_payment_admin () {
function theme_amazon_payment_button ($cid, $params = array()) {
global $config_amazon_payment_access_key_id;
global $config_amazon_payment_secret;
global $config_host;
global $config_protocol_security;
if (empty($config_amazon_payment_access_key_id)) {
error_register('Missing Amazon Access Key ID');
return '';
Expand All @@ -653,11 +651,11 @@ function theme_amazon_payment_button ($cid, $params = array()) {
, 'amount' => 'USD 1.1'
, 'cobrandingStyle' => 'logo'
, 'description' => 'Test Widget'
, 'ipnUrl' => $config_protocol_security . '://' . $config_host . base_path() . 'modules/amazon_payment/ipn.php'
, 'returnUrl' => $config_protocol_security . '://' . $config_host . crm_url('contact', array('query'=>array('cid'=>$cid, 'tab'=>'account')))
, 'ipnUrl' => protocol_security() . '://' . get_host() . base_path() . 'modules/amazon_payment/ipn.php'
, 'returnUrl' => protocol_security() . '://' . get_host() . crm_url('contact', array('query'=>array('cid'=>$cid, 'tab'=>'account')))
, 'processImmediate' => '1'
, 'cobrandingStyle' => 'logo'
, 'abandonUrl' => $config_protocol_security . '://' . $config_host . crm_url('contact', array('query'=>array('cid'=>$cid, 'tab'=>'account')))
, 'abandonUrl' => protocol_security() . '://' . get_host() . crm_url('contact', array('query'=>array('cid'=>$cid, 'tab'=>'account')))
);
// Use defaults for parameters not specified
foreach ($defaults as $key => $value) {
Expand Down
6 changes: 2 additions & 4 deletions crm/modules/billing/billing.inc.php
Expand Up @@ -167,8 +167,6 @@ function command_billing () {
* Send emails to any members with a positive balance.
*/
function command_billing_email () {
global $config_email_from;
global $config_site_title;
// Get balances and contacts
$cids = payment_contact_filter(array('balance_due'=>true));
$balances = payment_accounts(array('cid'=>$cids));
Expand All @@ -191,8 +189,8 @@ function command_billing_email () {
}
// Send email
$to = $cidToContact[$cid]['email'];
$subject = "[$config_site_title] Payment Due";
$from = $config_email_from;
$subject = "[" . get_site_title() . "] Payment Due";
$from = get_email_from();
$headers = "From: $from\r\nContent-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$message = "<p>Hello,<br/><br/>Your current account balance is $amount. To pay this balance using </p>";
Expand Down

0 comments on commit e6990f2

Please sign in to comment.