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

Split up admin setting to hide phone and email info #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 25 additions & 4 deletions src/simply-rets-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public static function register_admin_settings() {
register_setting('sr_admin_settings', 'sr_contact_page');
register_setting('sr_admin_settings', 'sr_show_listingmeta');
register_setting('sr_admin_settings', 'sr_show_listing_remarks');
register_setting('sr_admin_settings', 'sr_show_agent_contact');
register_setting('sr_admin_settings', 'sr_listing_gallery');
register_setting('sr_admin_settings', 'sr_show_leadcapture');
register_setting('sr_admin_settings', 'sr_leadcapture_recipient');
Expand Down Expand Up @@ -61,6 +60,17 @@ public static function register_admin_settings() {
register_setting('sr_admin_settings', 'sr_listing_force_image_https', array(
"default" => false
));

register_setting('sr_admin_settings', 'sr_show_agent_contact');
$show_contact_default = get_option('sr_show_agent_contact', false);

register_setting("sr_admin_settings", "sr_hide_agent_office_phone", array(
"default" => $show_contact_default
));

register_setting("sr_admin_settings", "sr_hide_agent_office_email", array(
"default" => $show_contact_default
));
}

public static $timezones = array(
Expand Down Expand Up @@ -266,10 +276,21 @@ public static function sr_admin_page() {
<td colspan="2">
<label>
<?php echo
'<input type="checkbox" id="sr_show_agent_contact" name="sr_show_agent_contact" value="1" '
. checked(1, get_option('sr_show_agent_contact'), false) . '/>'
'<input type="checkbox" id="sr_hide_agent_office_phone" name="sr_hide_agent_office_phone" value="1" '
. checked(1, get_option('sr_hide_agent_office_phone'), false) . '/>'
?>
Do not show agent/office phone numbers
</label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<?php echo
'<input type="checkbox" id="sr_hide_agent_office_email" name="sr_hide_agent_office_email" value="1" '
. checked(1, get_option('sr_hide_agent_office_email'), false) . '/>'
?>
Do not show Agent and Office phone number and email address (names are still shown).
Do not show agent/office email addresses
</label>
</td>
</tr>
Expand Down
14 changes: 9 additions & 5 deletions src/simply-rets-api-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,8 @@ public static function srResidentialDetailsGenerator( $listing ) {

///////////////////////////////////////////////////////

$show_contact_info = SrUtils::showAgentContact();
$hide_contact_phone = get_option("sr_hide_agent_office_phone", false);
$hide_contact_email = get_option("sr_hide_agent_office_email", false);

// agent data
$listing_agent_id = $listing->agent->id;
Expand All @@ -1010,7 +1011,7 @@ public static function srResidentialDetailsGenerator( $listing ) {
$has_agent_contact_info = !empty($listing->agent->contact)
AND !empty($listing->agent->contact->email);

if($show_contact_info AND $has_agent_contact_info) {
if(!$hide_contact_email AND $has_agent_contact_info) {
$listing_agent_email = $listing->agent->contact->email;
} else {
$listing_agent_email = '';
Expand Down Expand Up @@ -1046,11 +1047,14 @@ public static function srResidentialDetailsGenerator( $listing ) {
$listing_office_email = $has_office_contact_info ? $listing->office->contact->email : '';
$officeEmail = SimplyRetsApiHelper::srDetailsTable($listing_office_email, "Listing Office Email");

/* If show_contact_info is false, stub these fields */
if(!$show_contact_info) {
/* Hide contact info if settings are enabled */
if($hide_contact_email) {
$officeEmail = '';
}

if($hide_contact_phone) {
$agent_phone = '';
$officePhone = '';
$officeEmail = '';
}

/**
Expand Down
15 changes: 0 additions & 15 deletions src/simply-rets-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ public static function srShowListingMeta() {
return $show_listing_meta;
}

/**
* The naming for the database option is backwards.
* If it's 'checked', we _don't_ show data.
*/
public static function showAgentContact() {

if( get_option('sr_show_agent_contact') ) {
$show = false;
} else {
$show = true;
}

return $show;
}

/**
* Normalize a property type abbreviation into the full text.
*/
Expand Down